#!/bin/bash

# postinst script for system-zones-brand-s10
#
# see: dh_installdeb(1)

#set -e

# summary of how this script can be called:
#        * <postinst> \`configure' <most-recently-configured-version>
#        * <old-postinst> \`abort-upgrade' <new version>
#        * <conflictor's-postinst> \`abort-remove' \`in-favour' <package>
#          <new-version>
#        * <postinst> \`abort-remove'
#        * <deconfigured's-postinst> \`abort-deconfigure' \`in-favour'
#          <failed-install-package> <version> \`removing'
#          <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package

PATH=/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin
export PATH

if [ "${BASEDIR:=/}" = "/" ]; then
    BASEDIR=""
else
    BASEDIR_OPT="-b $BASEDIR"
fi

case "$1" in
    configure)
        chown root:bin $BASEDIR/usr/lib
	chown root:bin $BASEDIR/usr/lib/amd64
	chown root:bin $BASEDIR/usr/lib/brand
	chown root:bin $BASEDIR/usr/lib/brand/solaris10/amd64
	chown root:sys $BASEDIR/etc
	chown root:sys $BASEDIR/etc/brand
	chown root:sys $BASEDIR/etc/brand/solaris10
	chown root:sys $BASEDIR/etc/zones
	chown root:sys $BASEDIR/usr
	chown root:sys $BASEDIR/usr/kernel
	chown root:sys $BASEDIR/usr/kernel/brand
	chown root:sys $BASEDIR/usr/kernel/brand/amd64
	chown root:sys $BASEDIR/usr/lib/brand/solaris10
	chmod 0444 "$BASEDIR/etc/zones/SUNWsolaris10.xml"
	chown root:bin "$BASEDIR/etc/zones/SUNWsolaris10.xml"
	chmod 0444 "$BASEDIR/usr/lib/brand/solaris10/common.ksh"
	chown root:bin "$BASEDIR/usr/lib/brand/solaris10/common.ksh"
	chmod 0444 "$BASEDIR/usr/lib/brand/solaris10/config.xml"
	chown root:bin "$BASEDIR/usr/lib/brand/solaris10/config.xml"
	chmod 0444 "$BASEDIR/usr/lib/brand/solaris10/pkgrm.lst"
	chown root:bin "$BASEDIR/usr/lib/brand/solaris10/pkgrm.lst"
	chmod 0444 "$BASEDIR/usr/lib/brand/solaris10/platform.xml"
	chown root:bin "$BASEDIR/usr/lib/brand/solaris10/platform.xml"
	chmod 0444 "$BASEDIR/usr/lib/brand/solaris10/smf_disable.lst"
	chown root:bin "$BASEDIR/usr/lib/brand/solaris10/smf_disable.lst"
	chmod 0444 "$BASEDIR/usr/lib/brand/solaris10/version"
	chown root:bin "$BASEDIR/usr/lib/brand/solaris10/version"
	chmod 0755 "$BASEDIR/usr/lib/amd64/s10_brand.so.1"
	chown root:bin "$BASEDIR/usr/lib/amd64/s10_brand.so.1"
	chmod 0755 "$BASEDIR/usr/lib/amd64/s10_npreload.so.1"
	chown root:bin "$BASEDIR/usr/lib/amd64/s10_npreload.so.1"
	chmod 0755 "$BASEDIR/usr/lib/brand/solaris10/amd64/solaris10_librtld_db.so.1"
	chown root:bin "$BASEDIR/usr/lib/brand/solaris10/amd64/solaris10_librtld_db.so.1"
	chmod 0755 "$BASEDIR/usr/lib/brand/solaris10/attach"
	chown root:bin "$BASEDIR/usr/lib/brand/solaris10/attach"
	chmod 0755 "$BASEDIR/usr/lib/brand/solaris10/clone"
	chown root:bin "$BASEDIR/usr/lib/brand/solaris10/clone"
	chmod 0755 "$BASEDIR/usr/lib/brand/solaris10/detach"
	chown root:bin "$BASEDIR/usr/lib/brand/solaris10/detach"
	chmod 0755 "$BASEDIR/usr/lib/brand/solaris10/image_install"
	chown root:bin "$BASEDIR/usr/lib/brand/solaris10/image_install"
	chmod 0755 "$BASEDIR/usr/lib/brand/solaris10/p2v"
	chown root:bin "$BASEDIR/usr/lib/brand/solaris10/p2v"
	chmod 0755 "$BASEDIR/usr/lib/brand/solaris10/postattach"
	chown root:bin "$BASEDIR/usr/lib/brand/solaris10/postattach"
	chmod 0755 "$BASEDIR/usr/lib/brand/solaris10/poststate"
	chown root:bin "$BASEDIR/usr/lib/brand/solaris10/poststate"
	chmod 0755 "$BASEDIR/usr/lib/brand/solaris10/prestate"
	chown root:bin "$BASEDIR/usr/lib/brand/solaris10/prestate"
	chmod 0755 "$BASEDIR/usr/lib/brand/solaris10/preuninstall"
	chown root:bin "$BASEDIR/usr/lib/brand/solaris10/preuninstall"
	chmod 0755 "$BASEDIR/usr/lib/brand/solaris10/s10_boot"
	chown root:bin "$BASEDIR/usr/lib/brand/solaris10/s10_boot"
	chmod 0755 "$BASEDIR/usr/lib/brand/solaris10/s10_isaexec_wrapper"
	chown root:bin "$BASEDIR/usr/lib/brand/solaris10/s10_isaexec_wrapper"
	chmod 0755 "$BASEDIR/usr/lib/brand/solaris10/s10_native"
	chown root:bin "$BASEDIR/usr/lib/brand/solaris10/s10_native"
	chmod 0755 "$BASEDIR/usr/lib/brand/solaris10/s10_net_physical"
	chown root:bin "$BASEDIR/usr/lib/brand/solaris10/s10_net_physical"
	chmod 0755 "$BASEDIR/usr/lib/brand/solaris10/s10_replacefile"
	chown root:bin "$BASEDIR/usr/lib/brand/solaris10/s10_replacefile"
	chmod 0755 "$BASEDIR/usr/lib/brand/solaris10/s10_support"
	chown root:bin "$BASEDIR/usr/lib/brand/solaris10/s10_support"
	chmod 0755 "$BASEDIR/usr/lib/brand/solaris10/uninstall"
	chown root:bin "$BASEDIR/usr/lib/brand/solaris10/uninstall"
	[ -f $BASEDIR/etc/brand/solaris10/pkgrm.conf ] || cp -ax $BASEDIR/usr/share/doc/system-zones-brand-s10/examples/pkgrm.conf $BASEDIR/etc/brand/solaris10/pkgrm.conf
	chmod 0644 "$BASEDIR/etc/brand/solaris10/pkgrm.conf"
	chown root:sys "$BASEDIR/etc/brand/solaris10/pkgrm.conf"
	[ -f $BASEDIR/etc/brand/solaris10/smf_disable.conf ] || cp -ax $BASEDIR/usr/share/doc/system-zones-brand-s10/examples/smf_disable.conf $BASEDIR/etc/brand/solaris10/smf_disable.conf
	chmod 0644 "$BASEDIR/etc/brand/solaris10/smf_disable.conf"
	chown root:sys "$BASEDIR/etc/brand/solaris10/smf_disable.conf"
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/kernel/brand/amd64/s10_brand ] && rm -f $BASEDIR/usr/kernel/brand/amd64/s10_brand
	else
	    chmod 0755 "$BASEDIR/usr/kernel/brand/amd64/s10_brand"
	    chown root:sys "$BASEDIR/usr/kernel/brand/amd64/s10_brand"
	fi
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)
    ;;

    *)
        echo "postinst called with unknown argument '$1'" >&2
        exit 1
    ;;
esac



# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0

